//
//  AJJDView.m
//  yonghu
//
//  Created by mac on 2018/3/15.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "AJJDView.h"
#import "WyzAlbumViewController.h"

@implementation AJJDView

-(void)creatView1{
    self.backgroundColor=[UIColor whiteColor];
    
    _scrollView=[UIScrollView new];
    [self addSubview:_scrollView];
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(64);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    _scrollView.scrollsToTop =NO;
    _scrollView.showsVerticalScrollIndicator = FALSE;
    _scrollView.showsHorizontalScrollIndicator = FALSE;
    _scrollView.bounces = NO;
    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.viewController.automaticallyAdjustsScrollViewInsets = NO;
    }
    
   
    NSString *news_title=[_dic objectForKey:@"schedule_title"];
    
    CGSize size1=[ZQTools getNSStringSize:news_title andViewWight:_mainW-30 andFont:20];
    
    UILabel *titleLabel=[UILabel new];
    [_scrollView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.width.mas_equalTo(_mainW-20);
        make.top.mas_equalTo(20);
        make.height.mas_equalTo(size1.height);
    }];
    titleLabel.numberOfLines=0;
    titleLabel.text=news_title;
    titleLabel.textColor=ColorWithRGB(49, 49, 49);
    titleLabel.font=[UIFont systemFontOfSize:20];
    titleLabel.textAlignment=NSTextAlignmentCenter;
    
    
    
    NSString *news_content=[_dic objectForKey:@"schedule_content"];
    
    
    
    UILabel *contentLabel=[UILabel new];
    [_scrollView addSubview:contentLabel];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(titleLabel);
        make.top.mas_equalTo(titleLabel.mas_bottom).mas_equalTo(15);
        make.width.mas_equalTo(_mainW-30);
    }];
    
    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[news_content  dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSFontAttributeName:[UIFont systemFontOfSize:25.0f] } documentAttributes:nil error:nil];
    contentLabel.attributedText = attrStr;
    contentLabel.numberOfLines=0;
    contentLabel.textColor=ColorWithRGB(99, 99, 99);
    contentLabel.font=[UIFont systemFontOfSize:18];
    
    CGSize size2=[ZQTools getNSStringSize:[NSString stringWithFormat:@"\t%@",contentLabel.text] andViewWight:_mainW-30 andFont:18];
    
    _scrollView.contentSize = CGSizeMake(0,120+size1.height+size2.height);
}
-(void)creatView2{
    
    NSMutableArray *imageArr=[NSMutableArray arrayWithCapacity:0];
    NSArray *goods_image=[_dic objectForKey:@"img"];
    for (int i=0; i<goods_image.count; i++) {
        NSDictionary *imgDic=goods_image[i];
        NSString *si_img_url=[imgDic objectForKey:@"si_img_url"];
        si_img_url=[NSString stringWithFormat:@"%@%@",_addressUrl,si_img_url];
        [imageArr addObject:si_img_url];
    }
    [ZQTools getHederImage:UIViewContentModeScaleAspectFit :CGRectMake(0, 64, _mainW,  _mainH-64) :imageArr :10 :self :^(int value) {
        
        WyzAlbumViewController *wyzAlbumVC = [[WyzAlbumViewController alloc]init];

        wyzAlbumVC.currentIndex =value;//这个参数表示当前图片的index，默认是0

        //图片数组，可以是url，也可以是UIImage
        //第一种用url
        wyzAlbumVC.imgArr = imageArr;
        wyzAlbumVC.imageNameArray=nil;//图片名字数组可以为空
        //进入动画

        [self.viewController presentViewController:wyzAlbumVC animated:YES completion:^{

        }];
        
    }];
}

-(void)creatView3{
    NSMutableArray *imageArr=[NSMutableArray arrayWithCapacity:0];
    NSArray *goods_image=[_dic objectForKey:@"img"];
    for (int i=0; i<goods_image.count; i++) {
        NSDictionary *imgDic=goods_image[i];
        NSString *si_img_url=[imgDic objectForKey:@"si_img_url"];
        si_img_url=[NSString stringWithFormat:@"%@%@",_addressUrl,si_img_url];
        [imageArr addObject:si_img_url];
    }
    [ZQTools getHederImage:UIViewContentModeScaleAspectFit :CGRectMake(0, 64, _mainW,  _mainH-64) :imageArr :10 :self :^(int value) {
        
            WyzAlbumViewController *wyzAlbumVC = [[WyzAlbumViewController alloc]init];
    
            wyzAlbumVC.currentIndex =value;//这个参数表示当前图片的index，默认是0
    
            //图片数组，可以是url，也可以是UIImage
            //第一种用url
            wyzAlbumVC.imgArr = imageArr;
            wyzAlbumVC.imageNameArray=nil;//图片名字数组可以为空
            //进入动画
    
            [self.viewController presentViewController:wyzAlbumVC animated:YES completion:^{
    
    
            }];
    
    }];
    
    NSString *schedule_content=[_dic objectForKey:@"schedule_content"];
    CGSize size=[ZQTools getNSStringSize:schedule_content andViewWight:_mainW-30 andFont:16];
    
    UIView *view=[UIView new];
    [self addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(size.height+70);
    }];
    view.backgroundColor=[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.4];
    
    UILabel *label=[UILabel new];
    [view addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(20);
    }];
    label.text=schedule_content;
    label.font=[UIFont systemFontOfSize:16];
    label.textColor=[UIColor whiteColor];
    label.numberOfLines=0;
    
}

@end
